#ifndef MCGPP_MACROS_H
#define MCGPP_MACROS_H
#include <cstring>
#include <iostream>
#include "logger.h"
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

#define LOGCC(cond, newline) \
  !(cond) ? (void)0 :        \
  mcgpp::LoggerVoidify() & mcgpp::Logger(newline)

#define DBGCC(cond, newline) \
  !(cond) ? (void)0 :        \
  mcgpp::LoggerVoidify() & mcgpp::Logger(newline, __FILENAME__, __FUNCTION__, __LINE__)

#define LOG LOGCC(true, true)

#ifndef NDEBUG
#define DBG DBGCC(true, true)
#else
#define DBG DBGCC(false, true)
#endif

// 定义分割符
#if defined(_WIN32) || defined(_WIN64)
const char PATH_SEPARATOR = '\\';
const std::string PATH_SEPARATOR_STR = "\\";
#else
const char PATH_SEPARATOR = '/';
    const std::string PATH_SEPARATOR_STR = "/";
#endif

//打印报错信息
#define ERROREXIT(...) do { \
    std::string msg = #__VA_ARGS__; \
    std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " in " << __func__ << "(): " << msg << std::endl; \
    exit(EXIT_FAILURE); \
} while(0)


#if defined(__GNUC__) || defined(__clang__)
#define MCGPP_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
#define UTILS_UNUSED __attribute__ ((unused))
#define UNUSED(name) unused_ ## name UTILS_UNUSED
#else
#define MCGPP_ATTRIBUTE_ALWAYS_INLINE
#endif

#endif //MCGPP_MACROS_H
